﻿<% 
   Function tj()
		dim rs_1,sql_1,add,tjid

		Set Rs_1 = Server.CreateObject("Adodb.Recordset")

		Sql_1 = "select [id],[time] from qingtian_tj where DATEDIFF('d', time, now())=0 "
		Rs_1.Open Sql_1,conn,1,3
		if not (rs_1.bof and rs_1.eof)  then
			tjid=rs_1("id")
		else
			rs_1.addnew
			rs_1("time")=now
			rs_1.update
			tjid=rs_1("id")
		end if
		Rs_1.close


		Sql_1 = "select [ip],[count],[tjid],[time] from qingtian_tj_list where DATEDIFF('d', time, now())=0 and [ip]='"&Request.ServerVariables("REMOTE_ADDR")&"'"
		Rs_1.Open Sql_1,conn,1,3
		if not (rs_1.bof and rs_1.eof)  then
			rs_1("tjid")=tjid
			rs_1("count")=rs_1("count")+1
			rs_1("time")=now
			rs_1("ip")=Request.ServerVariables("REMOTE_ADDR")
			rs_1.update
			add=false
		else
			rs_1.addnew
			rs_1("tjid")=tjid
			rs_1("count")=1
			rs_1("time")=now
			rs_1("ip")=Request.ServerVariables("REMOTE_ADDR")
			rs_1.update
			add=true
		end if
		Rs_1.close

		if add=true then
			conn.execute("update qingtian_tj set [Count]=[Count]+1,ipCount=ipCount+1 where [id]="&tjid&"")
		else
			conn.execute("update qingtian_tj set [Count]=[Count]+1 where [id]="&tjid&"")
		end if

		set rs_1=nothing

    End Function
%>